/**
 * Created by pankajmishra on 14/02/15.
 */
define(['jquery', 'mustache','module/template/homeTemplate'], function($, mustache, template){
    return function(userId){

        var dom =  $( template['people-block']);
        dom.dialog({
            hide: { effect: "explode", duration: 100 },
            modal: true,
            minWidth : 700
        });

        dom.find('.js_submit').once('click', function(){

            var reason = dom.find('.reason').val().trim();

            if(reason.length == 0){
                alert('please specify reason for banning');
                return;
            }

            $.ajax(
                {
                    url : '/people/block',
                    type : "POST",
                    data :
                    {
                        reason : reason,
                        id : userId
                    }
                }
            ).done(function(data){
                    dom.dialog( "close" );
                });
        });
    }
});